package unei.net

/**
 * Created by sunlei on 2015/8/27.
 */

Socket socket=new Socket()
socket.connect(new InetSocketAddress("localhost",1024))

OutputStream ous=socket.getOutputStream()
BufferedReader is=new BufferedReader(new InputStreamReader(socket.getInputStream()));

ous.write("haha".getBytes())
ous.flush()

//byte[] buffer=new byte[2014]
//int n=0
//ins.readLine()
//while(true){
//    if((n=ins.read(buffer,0,1024))<=0)
//        continue;
//
//    println new String(buffer)
//    continue;
//}
println is.readLine()
ous.close()
is.close()
socket.close()